package com.bw.finance.conf;

import org.springframework.stereotype.Component;

import java.io.FileWriter;
import java.io.IOException;

/* *
 *类名：AlipayConfig
 *功能：基础配置类
 *详细：设置帐户有关信息及返回路径
 *修改日期：2017-04-05
 *说明：
 *以下代码只是为了方便商户测试而提供的样例代码，商户可以根据自己网站的需要，按照技术文档编写,并非一定要使用该代码。
 *该代码仅供学习和研究支付宝接口使用，只是提供一个参考。
 */
@Component
public class AlipayConfig {

//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
    /*@Value("${pay.appid}")
    public static String app_id;*/
    public static String app_id="2016102600766039";

    // 商户私钥，您的PKCS8格式RSA2私钥
   /* @Value("${pay.merchantprivatekey}")
    public static String merchant_private_key;*/
    public static String merchant_private_key="MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCNAQl+pd481tY/rcqzenqB0b92rAodJVyJSSdHFL50mOgL/BbRTdL9zSuFIGCQGL9s+HRLpigp22jHoA0eD4FDhxuEhkVGX6QUxTMqbMimDZuIg5WOUEwnHWBz6uRxcqDuxd7FFjC6s3ZfOJ4ynLTuB9xhOMyAQEBSn/waXR74A4QFYT8m7Rt05fb1jTm2dwlC8zVE6WJxGJ7ckKzYukU0gWiY9KmfSCVf/SdqrKpi+caC6FO1O1cPKGRbso6k+0lZ7wamyA+FaIS52IMLm2vzXSVcIR0G84r7G6055BUMdOYk2zBUOT0vMPeWZ6v0WUZrvYab1KSRMkgsSiaTCDWBAgMBAAECggEAT2zqIEDmcnbBsJUAvSCcqUuxAfPerpRBD8P5L/zrW1pWO4oAgF3KH9TWUuLuAb0u9v7s4z/xF8LTvr7VJL2vHo6YXYoUs5NkJZ7/N0KXs5GurrMQJ13rx4ywrBsAGzdql5U16uaZBFHat8B4vCGxePNMnCcWapfGo8QiiecybpkV3BU60koanxyGBKZ4j456n/WMtUIsriOmNf7lrXFIScsKfgDyTY9scZhOfezpaNQ/5IoYwpaqL2PBXTD83ZnmH9pjcbi5dTKitQKim8O3Rk/T0e0QRm9gmdi3OLCWsd4+Z6a25aaMfkGreK0y+31mW6zjMjpBCw5a7WkvpQtAAQKBgQDLFfzCu6OzbQR2/VFAySYJQkbfXM4Pe6gstQkfy6052BIXkbmHI2mb2eoN0aQW3YkNqbLlx27LmIhev8jfKiyPoiIEkTpaKpR6rYWJWZ8blqefr2qP1Mb5c2GRJ6GrlvuaELhPOCK8iJosRhgpbwAdpurtIKhLTH688USmGEJOQQKBgQCxviKPEBNde06r3y7Q27ycYFCZZy9rz3Z2eGFGHvMYw+eW3e6aBSLJwmal8JvKNbU7RSdbXfNKUZu3mfRvDXhnmXOAGaFFFUluDGXlUYWur+5mPA9wS7lLF+Ao4HhI4G1zbTmbe7FodQFMctculDaq0/IJBj6pSQhh9QIjX4qXQQKBgFthZF93MPy+VCD6cQI2wF+wK9W7m5jJ6m1bdGSTMDnz6IgkcRfGrnGLR066gxwqyM2WC0JrT4Za9xmzMD6CapSivq3RbzE9MZxV0d1wrzApxPkMZGWdt35tFXzMGWntQP8dAOHcf3zX9o9vZtXV9XZiMhlK9Y8UN37rDRmzlrpBAoGBAK9HtqLokoBMmn+Jv4w+Ndjsbm9pP22NEOCxxBO3b7oLb3Xq9GK1D+JxsHKSPcACiO+jObWzh7nRksNTsqZVXVilDi7Ul6Id5OT+mvmzFCb53hq5veva8Sapq+gDvPr5P1Zl7zpyl7hQMnCmi6emh+aczoGxw9eDax3W1T32+SBBAoGBAI9JdwFkpTJDAC6M/gbRHpbkV1CUStyDS1yJiCLbF6RtXSZivhhvyV4rLv0/RTk/waMoi4W6kckwRSAhes+wgLbFcFKYjWhzFEVOoEVV1FzjCri8x4DTYaU3XJNk1MPyKH1IvdpnYkZEye5QFpaLh5Hy1/VSmjnuMYZLAclLEqFD";

    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    /*@Value("${pay.alipaypublickey}")
    public static String alipay_public_key;*/
   public static String alipay_public_key="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwEJ5Z4QAWAsh0fFEvNg5zKZaVt61KWJIoJHk33efWjD0x/PjAOxweRaxQfvxV7Fg1YlROMLYx2ypwPIleb6Yhe+dKEZxmdWyyhaIl8cS6A8q74htqJDjJrkf2QadikKHsV2WWZLUGJ/IQb8ply8lf0vGiszLIJ3rmdxUpA/GrKNQov3Xx8BRqJ6lhJM7vXCFJ/bj6sLIM+1sETqZfOXqfSkNIagafwh+7mj0h5H1hCaWWmDdXBE2BPPR3K9xC/5BFz6aTWDgsoQxLQLks5A8v0+2omY4Eauz0IuyN8B6t+xHxSJaZuwvik6udYwn0a5ctUOb7ljDldwnbh+8O3FSVwIDAQAB";

    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    public static String notify_url = "http://localhost:8080/alipay.trade.page.pay-JAVA-UTF-8/notify_url.jsp";

    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    public static String return_url = "http://localhost:80/payResult.html";

    // 签名方式
    public static String sign_type = "RSA2";

    // 字符编码格式
    public static String charset = "utf-8";

    // 支付宝网关
    public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";

    // 支付宝网关
    public static String log_path = "C:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

